﻿using MediatR;
using T_Material.API.Application.Commands.StatisticsCommand;
using T_Material.Infrastructure.Interface;

namespace T_Material.API.Application.CommandHandlers.StatisticsHandlers
{
    public class StatisticsDeleteCommandHandler : IRequestHandler<StatisticsDeleteCommand, int>
    {
        private readonly IStatisticsRepository statisticsRepository;
        public StatisticsDeleteCommandHandler(IStatisticsRepository statisticsRepository)
        {
            this.statisticsRepository = statisticsRepository;
        }
        public async Task<int> Handle(StatisticsDeleteCommand request, CancellationToken cancellationToken)
        {
            var info= await statisticsRepository.GetModelAs(request.Id);
            info.IsDel = true;
            return await statisticsRepository.Update(info);
        }
    }
}
